import { createStore, combineReducers, applyMiddleware, Store } from 'redux'

import carReducer from './car/car'

import logger from 'redux-logger'


const reducer = combineReducers({
	car: carReducer
})

// 创建仓库
const store = createStore(reducer, applyMiddleware(logger))

// 订阅仓库
store.subscribe(() => {
	const state = store.getState();
	localStorage.setItem('carList', JSON.stringify(state.car.car))
})
// 定义仓库数据类型
export type RootState = ReturnType<typeof store.getState>
// 抛出仓库
export default store

